
import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersistence from 'vuex-persist'
 
const vuexLocal = new VuexPersistence({
    storage: window.sessionStorage
})
Vue.use(Vuex)
 
export default new Vuex.Store({
    state : {
        token:"",
        base_url:"http://dxsd.jlxmall.com",
        userInfo:{}
    },
    mutations : {
        LOGIN(state,data){
            state.token = data.token
        },
        ADD_USERINFO(state,data){
            state.userInfo = data
        },
        LOGINOUT(state){
            state.token = ""
            state.userInfo = {}
        },
        PRINTER(state,data){
            state.userInfo.key = data.key;
            state.userInfo.sn = data.sn;
        },
        STORE_STATUS(state){
            state.userInfo.is_open = state.userInfo.is_open?0:1
            // console.log(state.userInfo.is_open);
        }
    },
    getters:{
        token(state){
            return state.token
        },
        base_url(state){
            return state.base_url
        },
        userInfo(state){
            return state.userInfo
        }
    },
    plugins: [vuexLocal.plugin]
})
